﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
	public static class TypeExtensions
	{
		public static T[] GetCustomAttributes<T>(this Type type, bool inherit) where T : class {
			var attributes = type.GetCustomAttributes(typeof(T), inherit);

			if (attributes.Length == 0)
				throw new Exception();	//Note: Raise Exception

			//foreach (var attribute in attributes) {
			//    if(!(attribute is T))
			//        throw new ApplicationException();
			//}

			return attributes as T[];
		}

		public static T[] GetCustomAttributes<T>(this Type type) where T : class
		{
			return type.GetCustomAttributes<T>(true);
		}
	}
}
